<!DOCTYPE html>
<html lang="en" class="js csstransforms3d">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="Cache-Control" content="max-age=7200" />
    <meta name="generator" content="Hugo 0.70.0" />
    <meta name="description" content="">
    <meta name="buildDate" content="2020-07-30 15:35:12">


    <link rel="shortcut icon" href="https://shardingsphere.apache.org/document/current/img/favicon.png" type="image/x-icon" />

    <title>Code of Conduct :: ShardingSphere</title>
    
    
    <link href="https://shardingsphere.apache.org/community/css/nucleus.css?1596123312" rel="stylesheet">
    <link href="https://shardingsphere.apache.org/community/css/font-awesome.min.css?1596123312" rel="stylesheet">
    <link href="https://shardingsphere.apache.org/community/css/hybrid.css?1596123312" rel="stylesheet">
    <link href="https://shardingsphere.apache.org/community/css/featherlight.min.css?1596123312" rel="stylesheet">
    <link href="https://shardingsphere.apache.org/community/css/perfect-scrollbar.min.css?1596123312" rel="stylesheet">
    <link href="https://shardingsphere.apache.org/community/css/auto-complete.css?1596123312" rel="stylesheet">
    <link href="https://shardingsphere.apache.org/community/css/theme.css?1596123312" rel="stylesheet">
    <link href="https://shardingsphere.apache.org/community/css/hugo-theme.css?1596123312" rel="stylesheet">
    
      <link href="https://shardingsphere.apache.org/community/css/theme-black.css?1596123312" rel="stylesheet">
    

    <script src="https://shardingsphere.apache.org/community/js/jquery-2.x.min.js?1596123312"></script>
    
    <style type="text/css">
      :root #header + #content > #left > #rlblock_left{ 
          display:none !important;
      }
      
    </style>
    

  </head>
  <body class="" data-url="/en/contribute/code-conduct/">
    <nav id="sidebar" class="">



  <div id="header-wrapper">
    <div id="header">
      <a href="https://shardingsphere.apache.org/"><img src="https://shardingsphere.apache.org/document/current/img/logo_v2.png" /></a>

    </div>
    
  </div>

    <div class="highlightable">
    <ul class="topics">

        
          
          


 
  
    
    <li data-nav-id="/en/contribute/" title="Get Involved" class="dd-item 
        parent
        
        
        ">
      <a href="https://shardingsphere.apache.org/community/en/contribute/">
          <b>1. </b>Get Involved
          
      </a>
      
      
        <ul>
          
          
          
          
        
          
            
            


 
  
    
      <li data-nav-id="/en/contribute/subscribe/" title="Subscribe Guide" class="dd-item ">
        <a href="https://shardingsphere.apache.org/community/en/contribute/subscribe/">
        Subscribe Guide
        
        </a>
    </li>
     
  
 

            
          
            
            


 
  
    
      <li data-nav-id="/en/contribute/contributor/" title="Contributor Guide" class="dd-item ">
        <a href="https://shardingsphere.apache.org/community/en/contribute/contributor/">
        Contributor Guide
        
        </a>
    </li>
     
  
 

            
          
            
            


 
  
    
      <li data-nav-id="/en/contribute/committer/" title="Committer Guide" class="dd-item ">
        <a href="https://shardingsphere.apache.org/community/en/contribute/committer/">
        Committer Guide
        
        </a>
    </li>
     
  
 

            
          
            
            


 
  
    
      <li data-nav-id="/en/contribute/code-conduct/" title="Code of Conduct" class="dd-item active">
        <a href="https://shardingsphere.apache.org/community/en/contribute/code-conduct/">
        Code of Conduct
        
        </a>
    </li>
     
  
 

            
          
            
            


 
  
    
      <li data-nav-id="/en/contribute/document-contributor/" title="Documents Contributor Guide" class="dd-item ">
        <a href="https://shardingsphere.apache.org/community/en/contribute/document-contributor/">
        Documents Contributor Guide
        
        </a>
    </li>
     
  
 

            
          
            
            


 
  
    
      <li data-nav-id="/en/contribute/release/" title="ShardingSphere Release Guide" class="dd-item ">
        <a href="https://shardingsphere.apache.org/community/en/contribute/release/">
        ShardingSphere Release Guide
        
        </a>
    </li>
     
  
 

            
          
            
            


 
  
    
      <li data-nav-id="/en/contribute/release_ui/" title="ShardingSphere-UI Release Guide" class="dd-item ">
        <a href="https://shardingsphere.apache.org/community/en/contribute/release_ui/">
        ShardingSphere-UI Release Guide
        
        </a>
    </li>
     
  
 

            
          
            
            


 
  
    
      <li data-nav-id="/en/contribute/release-elasticjob/" title="ElasticJob Release Guide" class="dd-item ">
        <a href="https://shardingsphere.apache.org/community/en/contribute/release-elasticjob/">
        ElasticJob Release Guide
        
        </a>
    </li>
     
  
 

            
          
            
            


 
  
    
      <li data-nav-id="/en/contribute/release-elasticjob-ui/" title="ElasticJob-UI Release Guide" class="dd-item ">
        <a href="https://shardingsphere.apache.org/community/en/contribute/release-elasticjob-ui/">
        ElasticJob-UI Release Guide
        
        </a>
    </li>
     
  
 

            
          
            
            


 
  
    
      <li data-nav-id="/en/contribute/2fa/" title="2FA" class="dd-item ">
        <a href="https://shardingsphere.apache.org/community/en/contribute/2fa/">
        2FA
        
        </a>
    </li>
     
  
 

            
          
        
        </ul>
              
    </li>
  
 

          
          


 
  
    
    <li data-nav-id="/en/powered-by/" title="Powered By ShardingSphere" class="dd-item 
        
        
        
        ">
      <a href="https://shardingsphere.apache.org/community/en/powered-by/">
          <b>2. </b>Powered By ShardingSphere
          
      </a>
      
              
    </li>
  
 

          
          


 
  
    
    <li data-nav-id="/en/team/" title="Team" class="dd-item 
        
        
        
        ">
      <a href="https://shardingsphere.apache.org/community/en/team/">
          <b>3. </b>Team
          
      </a>
      
              
    </li>
  
 

          
          


 
  
    
    <li data-nav-id="/en/security/" title="security" class="dd-item 
        
        
        
        ">
      <a href="https://shardingsphere.apache.org/community/en/security/">
          <b>4. </b>security
          
      </a>
      
              
    </li>
  
 

          
         
    </ul>

    
    

    
    <section id="prefooter">
      <hr/>
      <ul>
      
        <li>
          <a class="padding">
            <i class="fa fa-fw fa-language"></i>
          <div class="select-style">
            <select id="select-language" onchange="location = this.value;">
          
          
          
              
              
                  
                    
                    
<option id="en" value="/community/en/contribute/code-conduct/" selected>English</option>
                    
                  
              
                  
              
          
              
              
                  
              
                  
                    
                    
<option id="cn" value="/community/cn/contribute/code-conduct/">简体中文</option>
                    
                  
              
          
        </select>
        <svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
          width="255px" height="255px" viewBox="0 0 255 255" style="enable-background:new 0 0 255 255;" xml:space="preserve">
          <g>
            <g id="arrow-drop-down">
              <polygon points="0,63.75 127.5,191.25 255,63.75 		" />
            </g>
          </g>
        </svg>
        </div>
        </a>
        </li>
       
      
      
      </ul>
    </section>
    
    <section id="footer">
      <p></p>

    </section>
  </div>
</nav>





        <section id="body">
        <div id="overlay"></div>
        <div class="padding highlightable">
              
              <div>
                <div id="top-bar">
                
                
                <div id="breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb">
                    <span id="sidebar-toggle-span">
                        <a href="#" id="sidebar-toggle" data-sidebar-toggle="">
                          <i class="fa fa-bars"></i>
                        </a>
                    </span>
                  
                  <span class="links">
                    
          
          
            
            
          
          
            
            
          
          
            <a href='https://shardingsphere.apache.org/community/en/'>ShardingSphere</a> > <a href='https://shardingsphere.apache.org/community/en/contribute/'>Get Involved</a> > Code of Conduct
          
         
          
         
          
           
                  </span>
                </div>
                
              </div>
            </div>
            

        
          <div id="chapter">
        
        <div id="body-inner">
          

        


<p>The following code of conduct is based on full compliance with <a href="https://www.apache.org/foundation/policies/conduct.html">ASF CODE OF CONDUCT</a>.</p>
<h2 id="development-guidelines">Development Guidelines</h2>
<ul>
<li>Write codes with heart. Pursue clean, simplified and extremely elegant codes. Agree with concepts in &lt;Refactoring: Improving the Design of Existing Code&gt; and &lt;Clean Code: A Handbook of Agile Software Craftsmanship&gt;.</li>
<li>Be familiar with codes already had, to keep consistent with the style and use.</li>
<li>Highly reusable, no duplicated codes or configurations.</li>
<li>Delete codes out of use in time.</li>
</ul>
<h2 id="contributor-covenant-submitting-of-conduct">Contributor Covenant Submitting of Conduct</h2>
<ul>
<li>Make sure all the test cases are passed, Make sure <code>./mvnw clean install</code> can be compiled and tested successfully.</li>
<li>Make sure the test coverage rate is not lower than the master branch.</li>
<li>Make sure to check codes with Checkstyle. codes that violate check rules should have special reasons. Find checkstyle template from <code>https://github.com/apache/shardingsphere/blob/master/src/resources/checkstyle.xml</code>, please use checkstyle <code>8.8</code> to run the rules.</li>
<li>Careful consideration for each <code>pull request</code>; Small and frequent <code>pull request</code> with complete unit function is welcomed.</li>
<li>Conform to <code>Contributor Covenant Code of Conduct</code> below.</li>
<li>If using IDEA，you can import the recommended <a href="https://shardingsphere.apache.org/community/data/shardingsphere-settings.jar">Settings</a>.</li>
</ul>
<h2 id="contributor-covenant-code-of-conduct">Contributor Covenant Code of Conduct</h2>
<ul>
<li>Use linux line separators.</li>
<li>Keep indents (including blank lines) consistent with the previous one.</li>
<li>Keep one blank line after class definition.</li>
<li>No meaningless blank lines.</li>
<li>Use meaningful class, method and variable names, avoid to use abbreviate.</li>
<li>Return values are named with <code>result</code>; Variables in the loop structure are named with <code>each</code>; Replace <code>each</code> with <code>entry</code> in map.</li>
<li>Exceptions when catch are named with <code>ex</code>; Exceptions when catch but do nothing are named with <code>ignored</code>.</li>
<li>Name property files with camel-case and lowercase first letters.</li>
<li>Split codes that need to add notes with it into small methods, which are explained with method names.</li>
<li>Have constants on the left and variable on the right in <code>=</code> and <code>equals</code> conditional expressions; Have variable on the left and constants on the right in <code>greater than</code> and <code>less than</code> conditional expressions.</li>
<li>Beside using same names as input parameters and global fields in assign statement, avoid using <code>this</code> modifier.</li>
<li>Design class as <code>final</code> class expect abstract class for extend.</li>
<li>Make nested loop structures a new method.</li>
<li>Order of members definition and parameters should be consistent during classes and methods.</li>
<li>Use guard clauses in priority.</li>
<li>Minimize the access permission for classes and methods.</li>
<li>Private method should be just next to the method in which it is used; writing private methods should be in the same as the appearance order of private methods.</li>
<li>No <code>null</code> parameters or return values.</li>
<li>Replace if else return and assign statement with ternary operator in priority.</li>
<li>Replace constructors, getters, setter methods and log variable with lombok in priority.</li>
<li>Use <code>LinkedList</code>  in priority. Use <code>ArrayList</code> for use index to get element only.</li>
<li>Use capacity based <code>Collection</code> such as <code>ArrayList</code>, <code>HashMap</code> must indicate initial capacity to avoid recalculate capacity.</li>
<li>Use English in all the logs and javadoc.</li>
<li>Include Javadoc, todo and fixme only in the comments.</li>
<li>Only <code>public</code> classes and methods need javadoc, other methods, classes and override methods do not need javadoc.</li>
</ul>
<h2 id="contributor-covenant-unit-test-of-conduct">Contributor Covenant Unit Test of Conduct</h2>
<ul>
<li>Test codes and production codes should follow the same kind of code of conduct.</li>
<li>Unit test should follow AIR (Automatic, Independent, Repeatable) principle.
<ul>
<li>Automatic: Unit test should run automatically, not interactively. Check test result manually and <code>System.out</code>, <code>log</code> are prohibited, use assert to check test results.</li>
<li>Independent: Call each other and sequence dependency during unit test cases are prohibited. Every test case should run independent.</li>
<li>Repeatable: Unit test case should not dependency external environment, they can run repeatable.</li>
</ul>
</li>
<li>Unit test should follow BCDE (Border, Correct, Design, Error) design principle.
<ul>
<li>Border: Border value test, test for loop border, special value and value sequence to get expect result.</li>
<li>Correct: Correct value test, test for correct value to get expect result.</li>
<li>Design: Design with production codes.</li>
<li>Error: Error value test, test for error input, exception to get expect result.</li>
</ul>
</li>
<li>Without particular reasons, test cases should be fully covered.</li>
<li>Every test case need precised assertion.</li>
<li>Environment preparation codes should be separate from test codes.</li>
<li>Only those that relate to junit <code>Assert</code>, hamcrest <code>CoreMatchers</code> and <code>Mockito</code> can use static import.</li>
<li>For single parameter asserts, <code>assertTrue</code>, <code>assertFalse</code>, <code>assertNull</code> and <code>assertNotNull</code> should be used.</li>
<li>For multiple parameter asserts, <code>assertThat</code> should be used.</li>
<li>For accurate asserts, try not to use <code>not</code>, <code>containsString</code> to make assertions.</li>
<li>Actual values of test cases should be named <code>actualXXX</code>, expected values <code>expectedXXX</code>.</li>
<li>Class for test case and <code>@Test</code> annotation do not need javadoc.</li>
</ul>
<h2 id="contributor-covenant-g4-code-of-conduct">Contributor Covenant G4 Code of Conduct</h2>
<ul>
<li>Common Conduct
<ul>
<li>Every line cannot over <code>200</code> chars, guarantee every line have complete semantics.</li>
</ul>
</li>
<li>Lexer Conduct
<ul>
<li>Every rule should be in single line, no empty line between rules.</li>
<li>Rule of lexer name should capitalization. If name composite with more than one word, use <code>underline</code> to separate. Rule name of <code>DataType</code> and <code>Symbol</code> should end with <code>underline</code>. If rule name is conflicted with ANTLR&rsquo;s keyword, should take an <code>underline</code> behind rule name.</li>
<li>For private rule in lexer should use <code>fragment</code>, rule with <code>fragment</code> should define behind of public rule which they served.</li>
<li>Common rule of lexer should put in file <code>Keyword.g4</code>, every database may has customized rule file by themselves. For example: <code>MySQLKeyword.g4</code>.</li>
</ul>
</li>
<li>Parser Conduct
<ul>
<li>After every rule finish, blank line should no indents.</li>
<li>No space before rule name definition. One space between <code>colon</code> and rule, <code>semicolon</code> should take a new line and keep indents (including blank lines) consistent with the previous one.</li>
<li>If a rule&rsquo;s branch is over than <code>5</code>, every branch take a new line.</li>
<li>Rule name of parser should same with java variable&rsquo;s camel case.</li>
<li>Define separate files for every SQL type, file name should consist of <code>database</code> + <code>SQL type</code> + <code>Statement</code>. For example: <code>MySQLDQLStatement.g4</code>.</li>
</ul>
</li>
</ul>


<footer class=" footline" >
	
</footer>


        
            </div> 
        
        </div> 
        

      </div>

    <div id="navigation">
        
        
        
        
            
            
                
                    
                    
                
                

                    
                    
                        
                    
                    

                    
                        
            
            
                
                    
                    
                
                

                    
                    
                    

                    
                        
            
            
                
                    
                        
                        
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                        
                        
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
            
        
        
        


        
            <a class="nav nav-prev" href="https://shardingsphere.apache.org/community/en/contribute/committer/" title="Committer Guide"> <i class="fa fa-chevron-left"></i></a>
        
        
            <a class="nav nav-next" href="https://shardingsphere.apache.org/community/en/contribute/document-contributor/" title="Documents Contributor Guide" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>
        
    </div>

    </section>
    
    <div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
      <div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
    </div>
    <script src="https://shardingsphere.apache.org/community/js/clipboard.min.js?1596123312"></script>
    <script src="https://shardingsphere.apache.org/community/js/perfect-scrollbar.min.js?1596123312"></script>
    <script src="https://shardingsphere.apache.org/community/js/perfect-scrollbar.jquery.min.js?1596123312"></script>
    <script src="https://shardingsphere.apache.org/community/js/jquery.sticky.js?1596123312"></script>
    <script src="https://shardingsphere.apache.org/community/js/featherlight.min.js?1596123312"></script>
    <script src="https://shardingsphere.apache.org/community/js/html5shiv-printshiv.min.js?1596123312"></script>
    <script src="https://shardingsphere.apache.org/community/js/highlight.pack.js?1596123312"></script>
    <script>hljs.initHighlightingOnLoad();</script>
    <script src="https://shardingsphere.apache.org/community/js/modernizr.custom.71422.js?1596123312"></script>
    <script src="https://shardingsphere.apache.org/community/js/learn.js?1596123312"></script>
    <script src="https://shardingsphere.apache.org/community/js/hugo-learn.js?1596123312"></script>

    

  </body>
</html>

